package com.evil.application.pojo.dto.view.config.filter;

import com.evil.common.application.enums.filter.FilterSourceTypeEnum;
import lombok.Data;

/**
 * 复制 应用筛选
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
public class CopyFilterReqDTO {

    private Long enterpriseId;

    /**
     * 复制源
     */
    private FilterSourceDTO source;

    /**
     * 复制目标
     */
    private FilterSourceDTO target;

    /**
     * 是否更新源信息
     */
    private Boolean updateSource;

    public CopyFilterReqDTO(FilterSourceTypeEnum sourceTypeEnum, Long enterpriseId, Long sourceId, Long targetId, boolean updateSource) {
        this.enterpriseId = enterpriseId;
        this.source = new FilterSourceDTO(sourceTypeEnum, sourceId);
        this.target = new FilterSourceDTO(sourceTypeEnum, targetId);
        this.updateSource = updateSource;
    }

    public static CopyFilterReqDTO copy(FilterSourceTypeEnum sourceTypeEnum, Long enterpriseId, Long sourceId, Long targetId) {
        return new CopyFilterReqDTO(sourceTypeEnum, enterpriseId, sourceId, targetId, false);
    }

    public static CopyFilterReqDTO replace(FilterSourceTypeEnum sourceTypeEnum, Long enterpriseId, Long sourceId, Long targetId) {
        return new CopyFilterReqDTO(sourceTypeEnum, enterpriseId, sourceId, targetId, true);
    }
}
